<div id="thread">
<?php foreach($threads->result() as $result) { 
	
	$next =  $this->uri->segment(4)+1;
	$previous =  $this->uri->segment(4)-1;
	echo '<div class="page">';
	echo anchor('designs/thread/' . $result->id, 'Back to grid view', array('class' => 'back'));
	if ($this->uri->segment(4) == '') {
	}
	else if ($this->uri->segment(4) == '1'){
	}
	else {
		echo anchor('designs/thread/' . $result->id . '/1', ' &laquo; first');
		echo anchor('designs/thread/' . $result->id . '/' . $previous, 'previous');
	}
	echo "Version " . $this->uri->segment(4) . " out of " . $count;
	$last = $count;
	if ($count <= $this->uri->segment(4)) {
	}
	else {
		echo anchor('designs/thread/' . $result->id . '/' . $next, 'next');
		echo anchor('designs/thread/' . $result->id . '/' . $last, 'last &raquo;');
	}
	echo '</div';
	echo '<h3>' . $result->name . '</h3>';
  
 } ?>


<?php if($designs->num_rows() == 0)
		{
		echo "<div class='error'>No designs in this thread!</div>";
		}
		else {
		foreach($designs->result() as $result) { ?>
	<p class="image"><?=img('designs/' . $result->image)?></p>
	<?=$result->body?>
	<?=$result->fname?>
	
<?php 
$designid = $result->designid;
} }
?>
<div id="talk">
<ol id="disc">
<?php if($designs->num_rows() > 0){foreach($comments->result() as $result) { ?>


	<li><div><h5><?=$result->fname?></h5><?=$result->thedate?></div><div class="body"><?=$result->body?></div></li>

<?php } ?>
</ol>
<?=form_open('designs/comment')?>
<ol>
<?=form_hidden('thisthread', $this->uri->segment(3));?>
<?=form_hidden('thisversion', $this->uri->segment(4));?>
<?=form_hidden('user', $this->users->getInfo($this->users->user,'id'));?>
<?=form_hidden('design', $designid);?>
<li><label>Comment</label><textarea name="body">
</textarea></li>
<li><input class="submit" type="submit" value="Comment on this design" /></li>
</ol>
</form>
</div>
<?php } ?>
</div>